#pragma once
#include<vector>

template<size_t N>
class bitset
{
public:
	bitset()
	{
		_tables.resize(N / 8 + 1);
	}

	void set(size_t num)
	{
		int i = num / 8;
		int j = num % 8;

		_tables[i] |= (1 << j);
	}

	void reset(size_t num)
	{
		int i = num / 8;
		int j = num % 8;

		_tables[i] &= (~(1 << j));
	}

	bool test(size_t num)
	{
		int i = num / 8;
		int j = num % 8;

		return _tables[i] & (1 << j);
	}

private:
	std::vector<char> _tables;
};


void bit_test()
{
	bitset<100> bs;
	bs.set(5);
	bs.set(4);
	bs.set(10);
	bs.set(20);

	cout << bs.test(5) << endl;
	cout << bs.test(4) << endl;
	cout << bs.test(10) << endl;
	cout << bs.test(20) << endl;
	cout << bs.test(21) << endl;
	cout << bs.test(6) << endl << endl;

	bs.reset(20);
	bs.reset(10);
	bs.reset(5);

	cout << bs.test(5) << endl;
	cout << bs.test(4) << endl;
	cout << bs.test(10) << endl;
	cout << bs.test(20) << endl;
	cout << bs.test(21) << endl;
	cout << bs.test(6) << endl;

	//bitset<-1> bs; ---> bitset<0xffffffff> bs;
}